<?php
/**
 * Analyse Variable
 * @author	zhangjian<smile_for_life@sina.cn>
 * @date	2014-01-14
 */
 class Task_Log_Pv implements IAnalyse
 {
	public static $data = array();
	
	public function init($data = array(),$options = array())
	{
		return true;
	}
	
	public function run($options = array(), $callback = null)
	{
		return true;
	}
	
	public function map($in = array(), $options = array())
	{
		$inAry = explode(' ',$in);
		return $inAry;
	}
	
	public function reduce($out = array(), $options = array())
	{
		if(is_array($out) && $out){
			foreach($out as $item){
				switch(true){
					case isset($item[6]) && preg_match('#/wp-content#i',$item[6]):
					break;
					case isset($item[6]) && preg_match('#/wp-includes#i',$item[6]):
					break;
					case isset($item[6]) && preg_match('#/wp-admin#i',$item[6]):
					break;
					case isset($item[6]) && preg_match('#/wp-admin#i',$item[6]):
					break;
					case isset($item[6]) && preg_match('#/images#i',$item[6]):
					break;
					case isset($item[6]) && preg_match('#/wp-cron#i',$item[6]):
					break;
					case isset($item[6]) && preg_match('#/favicon\.ico#i',$item[6]):
					break;
					case isset($item[6]) && preg_match('#/wp-login#i',$item[6]):
					break;
					default:
						// pv
						if( isset(self::$data[$item[6]]['pv']) ){
							self::$data[$item[6]]['pv']++;
						}else{
							self::$data[$item[6]]['pv'] = 1;
						}
						
						// ip
						if( isset(self::$data[$item[6]][$item[0]]) ){
							self::$data[$item[6]]['ip'][$item[0]]++;
						}else{
							self::$data[$item[6]]['ip'][$item[0]] = 1;
						}
				
				}
			}
		}
		
	}

 }